A potentiometer is a variable resistor. the 1st and 3rd pin can be either be connected to a live or a ground wire, and the 3rd pin must be the opposite of the 1st pin. The 2nd pin is the data pin, and you will need to connect it to any of the analog pins.

led digital pin

Alternatively, you can connect the data pin to a digital signal that is pwm-friendly (i.e. there is a "~" symbol next to the number.)

original code

as you see in the video, the led brightens and dampens multiple times with one full twist of the potentiometer. as the value input for analogWrite() always ranges from 0 to 255, since the potentiometer takes in a value between 0 to 1023, the resulting code is such that it brightens and then darkens. As such, it is important to map the values accordingly.

updated code

with the addition of the code where map is added, the code now ensures that the led is only at max brightness after 1 whole twist, or no light at the other end.

Here's the original code (with download link at image below!)

download here